package chapter03

import org.apache.spark.{SparkConf, SparkContext}

object Test14_Sample {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setMaster("local[*]").setAppName("sample")
    val sc = new SparkContext(conf)
    val value = sc.parallelize(1 to 100,1)
    println(value.collect().toList)
    //使用采样函数
    //不放回采样
    val value1 = value.sample(false, 0.2)
    println(value1.collect().toList)
    //放回的采样
    val value2 = value.sample(true, 0.1)
    println(value2.collect().toList)
  }
}
